"use client";
import { UserInfoRep, UserVipInfo, Wallet, checkCodeApi } from "@/api/user";
import {
BalanceContent,
BonusContent,
FreeContent,
ReplayContent,
} from "@/components/ModalPopup/WalletDescribeModal";
import TipsModal, { ModalProps } from "@/components/TipsModal";
import { Link, useRouter } from "@/i18n/routing";
import { useWalletStore } from "@/stores/useWalletStore";
import { WalletEnum } from "@/types";
import { vipImages } from "@/utils/constant";
import { flatPoint, percentage } from "@/utils/methods";
import { ProgressBar, Toast, Badge } from "antd-mobile";
import { useTranslations } from "next-intl";
import Image from "next/image";
import { Fragment, useRef, useState } from "react";
type Props = {
userInfo: UserInfoRep;
userMoney: Wallet;
userVip: UserVipInfo;
};
const VipCard = (props: { userVip: UserVipInfo }) => {
const { userVip } = props;
const t = useTranslations("ProfilePage");
// Vip 图标
const vipIconElement = vipImages.map((item, index) => {
if (item.leve === userVip.vip_level) {
return (
{item.leve}
);
}
});
return (
{vipIconElement}
{/*
{userVip.vip_exp}xp
*/}
VIP{userVip.vip_level}
{t("expTips", {
exp: flatPoint(userVip.vip_score_exp - userVip.vip_exp),
})}
VIP
{userVip.vip_next_level}
);
};
const WalletCard = (props: { userMoney: Wallet }) => {
const { userMoney } = props;
const t = useTranslations("ProfilePage");
const tipsRef = useRef(null);
const [tipsStatus, setTipsStatus] = useState("Bonus");
const modalHandler = (key: keyof typeof WalletEnum) => {
setTipsStatus(key);
tipsRef.current?.onOpen();
};
// 彩金、免费币、重玩币提现到钱包操作
const handleAcquire = async () => {
tipsRef.current?.onClose();
// checkCodeApi({ code: "123", mobile: "18215519037" })
// .then((res) => {
// if (res.code === 200) {
// Toast.show("领取成功!")
// setTimeout(() => {
// tipsRef.current?.onClose();
// }, 1000)
// return;
// }
// Toast.show("领取失败!");
// })
// .catch((error) => {
// Toast.show("领取失败!");
// });
};
return (
<>
{t("modalTitle")}
}
>
{/*现金*/}
{tipsStatus === WalletEnum.Balance ? : null}
{/* 彩金*/}
{tipsStatus === WalletEnum.Bonus ? : null}
{/* 免费币 */}
{tipsStatus === WalletEnum.Free ? : null}
{/* 重玩币 */}
{tipsStatus === WalletEnum.Replay ? : null}
modalHandler(WalletEnum.Balance)}
>
{t("balance")}
brl
{userMoney.score || 0.0}
modalHandler(WalletEnum.Bonus)}
>
{t("bonus")}
brl
{userMoney.point || 0.0}
modalHandler(WalletEnum.Free)}
>
{t("free")}
brl
{userMoney.free_score || 0.0}
modalHandler(WalletEnum.Replay)}
>
{t("replay")}
brl
{userMoney.lose_score || 0.0}
>
);
};
export const ProfileHeader = (props: Props) => {
const { userInfo, userVip } = props;
const t = useTranslations("ProfilePage");
const wallet = useWalletStore((state) => state.wallet);
const router = useRouter();
const handler = () => {
if (!!wallet.score) {
router.push("/withdraw");
} else {
Toast.show("no money ");
}
};
return (
<>
{t("Conta")}
{userInfo?.user_phone || ""}
{/*vipcard*/}
{t("Depósito")}
{t("Sacar")}
>
);
};